package com.xiyu.service.controller.admin.mailbox;
import com.xiyu.service.vo.mailbox.mailSignature.MailSignatureSingleGetAccountSignatureInput;
import com.xiyu.service.vo.mailbox.mailSignature.MailSignatureSaveAccountSignatureInput;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import com.xiyu.service.vo.mailbox.mailSignature.MailSignatureListAccountSignatureOutput;
import com.xiyu.service.vo.mailbox.mailSignature.MailSignatureUpdateSignatureInput;
import com.xiyu.service.vo.mailbox.mailSignature.MailSignatureCreateSignatureInput;
import com.xiyu.service.vo.mailbox.mailSignature.MailSignatureListOutput;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.service.mailbox.MailSignatureService;

import java.util.List;

@Tag(name = "邮箱签名")
@RestController
@RequestMapping("/mailbox/mail-signature")
@Validated
public class MailSignatureController {

    @Resource
    private MailSignatureService mailSignatureService;

    @GetMapping("/list")
    @Operation(summary = "查询签名列表")
    public CommonResult<List<MailSignatureListOutput>> list() {
        return success(mailSignatureService.list());
    }

    @PostMapping("/create-signature")
    @Operation(summary = "新增签名")
    public CommonResult<Long> createSignature(@Valid @RequestBody MailSignatureCreateSignatureInput inputVO) {
        return success(mailSignatureService.createSignature(inputVO));
    }

    @PutMapping("/update-signature")
    @Operation(summary = "更新签名")
    public CommonResult<Boolean> updateSignature(@Valid @RequestBody MailSignatureUpdateSignatureInput inputVO) {
        return success(mailSignatureService.updateSignature(inputVO));
    }

    @DeleteMapping("/deleted-signature")
    @Operation(summary = "删除签名")
    @Parameter(name = "id", description = "邮箱签名主键ID", example = "")
    public CommonResult<Boolean> deletedSignature(@RequestParam("id") Long id) {
        return success(mailSignatureService.deletedSignature(id));
    }

    @GetMapping("/list-account-signature")
    @Operation(summary = "查询账号默认签名")
    public CommonResult<List<MailSignatureListAccountSignatureOutput>> listAccountSignature() {
        return success(mailSignatureService.listAccountSignature());
    }

    @PostMapping("/save-account-signature")
    @Operation(summary = "保存账号默认签名")
    public CommonResult<Boolean> saveAccountSignature(@Valid @RequestBody List<MailSignatureSaveAccountSignatureInput> inputVO) {
        return success(mailSignatureService.saveAccountSignature(inputVO));
    }

    @GetMapping("/single-get-account-signature")
    @Operation(summary = "获取单个账号签名")
    public CommonResult<String> singleGetAccountSignature(@Valid MailSignatureSingleGetAccountSignatureInput inputVO) {
        return success(mailSignatureService.singleGetAccountSignature(inputVO));
    }

}
